package array;

import java.util.Arrays;
public class ArrayDemo03 {
    public static void main(String[] args) {

        int[] array = {1,8,6,9,12,88,45,5,3};
        BBSort(array);

        System.out.println(Arrays.toString(array));
    }

    //冒泡排序
    public static void BBSort(int[] array){
        for (int i = 0; i < array.length-1; i++) {
            boolean flag = false;

            for (int j = 0; j < array.length-1; j++) {
                if(array[j+1]<array[j]){
                    int temp = 0;
                    temp = array[j+1];
                    array[j+1] = array[j];
                    array[j] = temp;
                    flag = true;
                }
            }

            if (!flag){
                break;
            }
        }
    }
}
